<?php
require_once 'connexion (2).php';

function mDate($d)
{
    if($d!="")
    {
    list($annee, $mois, $jour) = explode("-", $d); 
    list($j) = explode(" ", $jour);
    //list($h, $min, $s) = explode(":", $t);
   // $t=" ";
                        if($mois==1)
                        {
        $m="Jan";
                        }else if($mois==2){
        $m="Fév";
                        }else if($mois==3){
        $m="Mar";
                        }else if($mois==4){
        $m="Avr";
                        }else if($mois==5){
        $m="Mai";
                        }else if($mois==6){
        $m="Juin";
                        }else if($mois==7){
        $m="Jull";
                        }else if($mois==8){
        $m="Aoû";
                        }else if($mois==9){
        $m="Sep";
                        }else if($mois==10){
        $m="Nov";
                        }else if($mois==11){
        $m="Oct";
                        }else if($mois==12){
        $m="Déc";
                        }
                        
                        /*$h=date("H");
                        $min=date("m",$d);
                        $s=date("s",$d);
                        $jour1=date("d",$d);
                        $m1=date("M",$d);
                        $annee1=date("Y",$d);*/
    $dateRet=$j." ".$m." ".$annee;
    }else{$dateRet="";}
    return $dateRet;
}
/*
$acti=null;

if($acti=='tel')
{
     if(!(isset($_GET["id"])))
                {
                    die("Parametre 'id' absent");
                }
                else
                {
                   $id1=$_GET["id"];
		}
                
function TelechCompte($id)
{
    
    $wr="";
    
    $req_c="select * from personne as p, stage as s, eleve as e where p.IDPERSONNE=e.IDELEVE AND e.IDELEVE=s.IDELEVE AND IDSTAGE=".$id;
                $resu_cr=$connexion->query($req_c);
                if ($rep1=$resu_cr->fetch(PDO::FETCH_ASSOC))
                {
                    
                    $nom=$rep1["NOMPERSONNE"];
                    $pnom=$rep1["PRENOMPERSONNE"];
                    $dated=$rep1["DATEDEBUT"];
                    $d=  mDate($dated);

                    $wr+="<center>Stage Numéro : ".$rep1["IDSTAGE"]."</center><br><br>";
                    //$wr+="Nom : ".$rep1["IDPERSONNE"]."<br>";
                    $wr+="Nom : ".$rep1["NOMPERSONNE"]."<br>";
                    $wr+="Prénom : ".$rep1["PRENOMPERSONNE"]."<br>";
                    $wr+="Sujet : ".$rep1["SUJETSTAGE"]."<br>";
                    $wr+="Date début : ".$rep1["DATEDEBUT"]."<br>";
                    $wr+="Date fin : ".$rep1["DATEFIN"]."<br><br><br><br>";
                    
                    
    
                $req_ac="select * from compterendu where IDSTAGE=".$id." order by DATESAISIE";
                     $resu_a=$connexion->query($req_ac);
                          while ($repac=$resu_a->fetch(PDO::FETCH_ASSOC))
                            {
                                $wr+="<table class='tabcom' border='0'><tr><td>".mDate($repac['DATESAISIE'])."<br>______________________<br>
                                      ".$repac['CORPS']."<br>-------------------------------</td></tr></table>";
                            
                                
                            }
    
     }
    
    
     $fp = fopen('telechargement/'.$nom.' '.$pnom.'-'.$d.'.doc', 'w');
fwrite($fp, $wr);
fclose($fp);
}

}
    
    
  function creerCP($id)
{
    
    
            $req_c1="select * from personne as p, stage as s, eleve as e, entreprise as ent where ent.IDENTREPRISE=s.IDENTREPRISE AND p.IDPERSONNE=e.IDELEVE AND e.IDELEVE=s.IDELEVE AND IDSTAGE=".$id;
                $resu_cr1=$connexion->query($req_c1);
                
               /*$resu_cr1=$connexion->prepare($req_c1);
               $resu_cr1->execute();* /
    
                if($rep1 == $resu_cr1->fetch(PDO::FETCH_ASSOC))
                {
        /* @var $nomE type * /
                    $nomE=$rep1["NOMENTREPRISE"];
                    $nom=$rep1["NOMPERSONNE"];
                    $pnom=$rep1["PRENOMPERSONNE"];
                    $dated=$rep1["DATEDEBUT"];
                    $d=  mDate($dated);

                    $wr="<center style='font-size:150%; border: 2px solid black; color:blue;' >Stage chez : ".$nomE."</center><br><br>";
                    //$wr+="Nom : ".$rep1["IDPERSONNE"]."<br>";
                    $wr=$wr."<center style='font-size:150%; border: 2px solid black; color:blue;' ><i style='border: 2px solid black; color:blue;'>Nom : ".$rep1["NOMPERSONNE"]."<br>";
                    $wr=$wr."Prénom : ".$rep1["PRENOMPERSONNE"]."<br>";
                    $wr=$wr."Sujet : ".$rep1["SUJETSTAGE"]."<br>";
                    $wr=$wr."Date début : ".$rep1["DATEDEBUT"]."<br>";
                    $wr=$wr."Date fin : ".$rep1["DATEFIN"]."</i></center><br><br><br><br>";
                }
                  
    
              /*$req_ac1="select * from compterendu where IDSTAGE=".$id." order by DATESAISIE";
                  $resu_a1=$connexion->query($req_ac1);
                  while ($repac=$resu_a1->fetch(PDO::FETCH_ASSOC))
                  {
                     $wr=$wr."<table class='tabclom'  ><tr style='font-size:150%; color:lime; border:3px #555;'><td>Le ".mDate($repac['DATESAISIE'])."<br><br>
                     ".$repac['CORPS']."<br></td></tr></table>";
                            
                                
                  }  
                   echo $wr;* /
     
     
    
     $fp = fopen('telechargement/compteRendu/'.$nom.' '.$pnom.'-stage-du-'.$d.'.doc', 'w');
fwrite($fp, $wr);
fclose($fp);




}

function tel()
{
    $tel='telechargement/compteRendu/'.$nom.' '.$pnom.'-stage-du-'.$d.'.doc';
    return $tel;
}*/

?>
